package cn.admin.remoting.serialize;

import com.caucho.hessian.io.SerializerFactory;

public abstract class SerializationUtil {

    private static final SerializationUtil impl;


    public static void addCustom(String className,CustomSerialization<?> custom) {
        impl.addCustom0(className,custom);
    }

    public abstract void addCustom0(String className,CustomSerialization<?> custom);

    public static void removeCustom(String className) {
        impl.removeCustom0(className);
    }

    public abstract void removeCustom0(String className);

    public static CustomSerialization<Object> getCustom(String className) {
        return impl.getCustom0(className);
    }

    public abstract CustomSerialization<Object> getCustom0(String className);

    public static CustomSerialization<Object> getDefaultSerialization() {
        return impl.getDefaultSerialization0();
    }

    public abstract CustomSerialization<Object> getDefaultSerialization0();

    public abstract boolean setReuseSerialization(boolean flag);

    public abstract boolean isReuseSerialization();

    public abstract SerializerFactory getHessianSerializerFactory();

    public static SerializationUtil getImpl() {
        return impl;
    }

    static {
        String implClazzName = "cn.admin.remoting.serialize.impl.SerializationUtilImpl";
        try {
            impl = (SerializationUtil) Class.forName(implClazzName).newInstance();

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            throw new RuntimeException("创建实例失败.",e);
        }
    }

}
